/**
 * 该函数用于更改jQuery中AJAX请求的默认设置选项。之后执行的所有AJAX请求，
 * 如果对应的选项参数没有设置，将使用更改后的默认设置。
 */
$.ajaxSetup({
	dataType: "json",
	contentType: "application/json",
	cache: false,
	// async : false 默认同步加载
	//type: "POST" , 默认使用POST方式

});
$(function () {
	gridValidate('bodyGrid');
    $("#jqGrid").jqGrid({
        url: '../dictcoefficient/list',
        datatype: "json",
        colModel: [			
			{ label: 'id', name: 'id', width: 50,hidden:true, key: true },
			{ label: '编号', name: 'code', width: 80 }, 			
			{ label: '系数名称', name: 'name', width: 80 }, 			
			{ label: '计算公式id', name: 'type', width: 80 }, 
			{ label: '薪资类型', name: 'wagesTypeId', width: 80 },
			{ label: '排序', name: 'orderno', width: 80 },  			
			{ label: '备注', name: 'memo', width: 80 }, 			
			{ label: '创建时间', name: 'createtime',hidden:true, width: 80 }, 			
			{ label: '创建人', name: 'createby',hidden:true, width: 80 }, 			
			{ label: '修改时间', name: 'updatetime',hidden:true, width: 80 }, 			
			{ label: '修改人', name: 'updateby',hidden:true, width: 80 }, 			
			{ label: '状态', name: 'state', width: 80 }			
        ],
		viewrecords: true,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
		arrayNewListC:[],
		columnContC:[],
		arrayNewListP:[],
		columnContP:[],
		title: null,
		billdata:"",
		dictCoefficient: {}
	},
	methods: {
		getplist:function(jfids,jfnames){
			//console.log(jfids,jfnames)
			//新建一个数组，存放已勾选的id
			/*if(jfids ==null|| jfids ==""||jfnames ==null|| jfnames ==""){
				
			}else{
				vm.arrayNewListP=jfids.split(",");
					vm.columnContP=jfnames.split(",");
			}*/
			//console.log(arrayNewList,columnCont)
			$("#pqgrid").jqGrid({
				url: '../dictwagestype/listXtd',
		        datatype: "json",
		        colModel: [			
					{ label: 'id', name: 'id', width: 50, key: true,hidden: true },
					{ label: '名称', name: 'name', width: 80 }, 			
					{ label: '岗位id', name: 'jobid', width: 40,hidden:true }, 	
					{ label: '岗位', name: 'jobName', width: 40 },
					{ label: '结算方式（0：固定薪资，1：业绩提成）', name: 'statementstype', width: 140, formatter: function(value, options, row){
						return value === 0 ? 
								'<span class="label label-primary">固定薪资</span>' : 
								'<span class="label label-info">业绩提成</span>';
						}}, 			
					{ label: '固定薪资', name: 'fixedpay', width: 60 }, 			
					{ label: '排序', name: 'orderno', width: 40}, 			
//					{ label: '备注字段', name: 'excol', width: 80 }, 			
					{ label: '备注', name: 'memo', width: 80 }, 			
					{ label: '创建时间', name: 'createtime', width: 80,hidden: true }, 			
					{ label: '创建人', name: 'createby', width: 80,hidden: true }, 			
					{ label: '修改时间', name: 'updatetime', width: 80,hidden: true }, 			
					{ label: '修改人', name: 'updateby', width: 80,hidden: true }, 			
					{ label: '状态', name: 'state', width: 60, formatter: function(value, options, row){
						return value === false ? 
								'<span class="label label-danger">禁用</span>' : 
								'<span class="label label-success">正常</span>';
						}},			
		        ],
			       
					viewrecords: true,
					height: window.screen.availHeight-250,
			        rowNum: 10,
					rowList : [10,30,50],
			        rownumbers: true, 
			        rownumWidth: 50, 
			        width:window.screen.availWidth-250,  
			        autowidth:false,  
			        shrinkToFit: true,
			        multiselect: true,
			        pager: "#jqGridPager2",
			        jsonReader : {
			            root: "page.list",
			            page: "page.currPage",
			            total: "page.totalPage",
			            records: "page.totalCount"
			        },
			        prmNames : {
			            page:"page", 
			            rows:"limit", 
			            sort:"sort",//需要排序的列
			            order: "order"//asc/desc
			        },
			        onSelectAll:function(aRowids,status){
			            if(status==true){
			                //循环aRowids数组，将code放入arrayNewList数组中
			                $.each(aRowids,function(i,item){
			                   saveData(item);
			                })
			            }else{
			                //循环aRowids数组，将code从arrayNewList中删除
			                $.each(aRowids,function(i,item){
			                   deleteIndexData(item);
			                })
			            }

			        },
			        onSelectRow:function(aRowids,status){
			            if(status==true){
			               saveData(aRowids);
			            }else{
			               deleteIndexData(aRowids);
			            }

			        },
		        gridComplete:function(){
		        	var ids = jQuery("#pqgrid").jqGrid('getDataIDs');
		        	/*if(ids.length==0){
					     alert("不存在该条数据，请正确输入查询条件");
					     }*/
					if(ids.length>0 && vm.arrayNewListC.length>0) {
						for(var i=0;i<ids.length;i++) {
							for(var n=0;n<vm.arrayNewListC.length;n++) {
								if(ids[i]== vm.arrayNewListC[n] ){
									$("#pqgrid").setSelection(ids[i],true);
									break;
								}
							}
						}
					}
		        	//隐藏grid底部滚动条
	        	$("#pqgrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
		        	layer.open({
		        		type : 1,
//		        		offset:'50px',
		        		title : "薪资类型",
		        		closeBtn :1,  
		        		maxmin:1,
		        		btn : [ '确认', '取消' ],
		        		area : [ "100%", "100%" ],
		        		skin : 'layui-layer-molv', // 
		        		shade:0,
		        		shadeClose : false,
		        		content : $('#plist'),
		        		cancel: function(index, layero){ 
		        			vm.arrayNewListP=[];
		        			vm.columnContP=[];
		        			layer.close(index)
		        			  
		        			},
	        			btn2: function(index, layero){
	        				vm.arrayNewListP=[];
		        			vm.columnContP=[];
		        			layer.close(index)
	        			  },
		        		yes:function(index,layero){
		        			if(vm.arrayNewListP.length==0){
		        				layer.alert('请选择一条记录');
		        				return ;
		        			}
		        			if(vm.arrayNewListP.length!=1){
		        				layer.alert('只能选择一条记录');
		        				return ;
		        			}
		        		    var id=vm.arrayNewListP.join(",")
		        			var rowName=vm.columnContP.join(",");
		        			vm.dictCoefficient.wagesTypeId=id;
		        			if(vm.arrayNewListP==undefined){
		        				vm.dictCoefficient.wagesTypeName="";
		        			}else{
		        				vm.dictCoefficient.wagesTypeName=rowName;
		        			}
		        			$('#wagestypename').val(rowName);
		        			if(vm.arrayNewListP.length!=0){
		        				vm.arrayNewListP=[];
		        			vm.columnContP=[];
		        			layer.close(index);
		        		}//此时你只需要把获得的index，轻轻地赋予layer.close即可
		        		  }
		        	});
		        }
			}); 	
			function saveData(obj){
				if(vm.arrayNewListC.length>0){
		    		for(i = 0; i < vm.arrayNewListC.length; i++){
		                if (vm.arrayNewListC[i] == obj){
		                    return;
		                }
		                //console.log(columnCont)
		             }	
		    	}
				vm.arrayNewListP.push(obj);
	            var rowData = $("#pqgrid").jqGrid("getRowData", obj);
	            
	            vm.columnContP.push(rowData.name);
	        }
	        function deleteIndexData(obj){
	            //获取obj在arrayNewList数组中的索引值
	        	var rowData = $("#pqgrid").jqGrid("getRowData", obj);
	            for(i = 0; i < vm.arrayNewListP.length; i++){
	                if (vm.arrayNewListP[i] == obj){
	                    //根据索引值删除arrayNewList中的数据
	                	RemoveValByIndex(vm.arrayNewListP, i);
	                	RemoveValByIndex(vm.columnContP, i);
	                    i--;
	                }
	             }
	        }
			//解决jqGrid不能刷新的问题
			$("#pqgrid").jqGrid('clearGridData');
			$("#pqgrid").trigger('reloadGrid');
		
		},
		getclist:function(jfids,jfnames){
			//console.log(jfids,jfnames)
			//新建一个数组，存放已勾选的id
			/*if(jfids ==null|| jfids ==""||jfnames ==null|| jfnames ==""){
				
			}else{
				vm.arrayNewListC=jfids.split(",");
					vm.columnContC=jfnames.split(",");
			}*/
			//console.log(arrayNewList,columnCont)
			$("#cqgrid").jqGrid({
				url: '../dictcalculationformula/list',
		        datatype: "json",
		        colModel: [			
					{ label: 'id', name: 'id', hidden:true,width: 50, key: true },
					{ label: '编号', name: 'code', width: 80 }, 			
					{ label: '计算公式名称', name: 'name', width: 80 }, 			
					{ label: '排序', name: 'orderno', width: 80 }, 			
					{ label: '备用字段', name: 'excol', width: 80 }, 			
					{ label: '备注', name: 'memo', width: 80 }, 			
					{ label: '创建时间', hidden:true,name: 'createtime', width: 80 }, 			
					{ label: '创建人', hidden:true,name: 'createby', width: 80 }, 			
					{ label: '修改时间', hidden:true,name: 'updatetime', width: 80 }, 			
					{ label: '修改人', hidden:true,name: 'updateby', width: 80 }, 			
					{ label: '状态', name: 'state', width: 80 }			
		        ],
			       
					viewrecords: true,
					height: window.screen.availHeight-250,
			        rowNum: 10,
					rowList : [10,30,50],
			        rownumbers: true, 
			        rownumWidth: 50, 
			        width:window.screen.availWidth-250,  
			        autowidth:false,  
			        shrinkToFit: true,
			        multiselect: true,
			        pager: "#jqGridPager1",
			        jsonReader : {
			            root: "page.list",
			            page: "page.currPage",
			            total: "page.totalPage",
			            records: "page.totalCount"
			        },
			        prmNames : {
			            page:"page", 
			            rows:"limit", 
			            sort:"sort",//需要排序的列
			            order: "order"//asc/desc
			        },
			        onSelectAll:function(aRowids,status){
			            if(status==true){
			                //循环aRowids数组，将code放入arrayNewList数组中
			                $.each(aRowids,function(i,item){
			                   saveData(item);
			                })
			            }else{
			                //循环aRowids数组，将code从arrayNewList中删除
			                $.each(aRowids,function(i,item){
			                   deleteIndexData(item);
			                })
			            }

			        },
			        onSelectRow:function(aRowids,status){
			            if(status==true){
			               saveData(aRowids);
			            }else{
			               deleteIndexData(aRowids);
			            }

			        },
		        gridComplete:function(){
		        	var ids = jQuery("#cqgrid").jqGrid('getDataIDs');
		        	/*if(ids.length==0){
					     alert("不存在该条数据，请正确输入查询条件");
					     }*/
					if(ids.length>0 && vm.arrayNewListC.length>0) {
						for(var i=0;i<ids.length;i++) {
							for(var n=0;n<vm.arrayNewListC.length;n++) {
								var rowData = $("#cqgrid").jqGrid("getRowData", ids[i] );
								if(rowData.code== vm.arrayNewListC[n] ){
									$("#cqgrid").setSelection(ids[i],true);
									break;
								}
							}
						}
					}
		        	//隐藏grid底部滚动条
	        	$("#cqgrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
		        	layer.open({
		        		type : 1,
//		        		offset:'50px',
		        		title : "计算公式",
		        		closeBtn :1,  
		        		maxmin:1,
		        		btn : [ '确认', '取消' ],
		        		area : [ "100%", "100%" ],
		        		skin : 'layui-layer-molv', // 
		        		shade:0,
		        		shadeClose : false,
		        		content : $('#clist'),
		        		cancel: function(index, layero){ 
		        			vm.arrayNewListC=[];
		        			vm.columnContC=[];
		        			layer.close(index)
		        			  
		        			},
	        			btn2: function(index, layero){
	        				vm.arrayNewListC=[];
		        			vm.columnContC=[];
		        			layer.close(index)
	        			  },
		        		yes:function(index,layero){
		        			if(vm.arrayNewListC.length==0){
		        				layer.alert('请选择一条记录');
		        				return ;
		        			}
		        			if(vm.arrayNewListC.length!=1){
		        				layer.alert('只能选择一条记录');
		        				return ;
		        			}
		        		    var code=vm.arrayNewListC.join(",")
		        			var rowName=vm.columnContC.join(",");
		        			vm.dictCoefficient.type=code;
		        			if(vm.arrayNewListC==undefined){
		        				vm.dictCoefficient.typeName="";
		        			}else{
		        				vm.dictCoefficient.typeName=rowName;
		        			}
		        			$('#classicalname').val(rowName);
		        			if(vm.arrayNewListC.length!=0){
		        				vm.arrayNewListC=[];
		        			vm.columnContC=[];
		        			layer.close(index);
		        		}//此时你只需要把获得的index，轻轻地赋予layer.close即可
		        		  }
		        	});
		        }
			}); 	
			function saveData(obj){
				if(vm.arrayNewListC.length>0){
		    		for(i = 0; i < vm.arrayNewListC.length; i++){
		                if (vm.arrayNewListC[i] == obj){
		                    return;
		                }
		                //console.log(columnCont)
		             }	
		    	}
				
	            var rowData = $("#cqgrid").jqGrid("getRowData", obj);
	            vm.arrayNewListC.push(rowData.code);
	            vm.columnContC.push(rowData.name);
	        }
	        function deleteIndexData(obj){
	            //获取obj在arrayNewList数组中的索引值
	        	var rowData = $("#cqgrid").jqGrid("getRowData", obj);
	            for(i = 0; i < vm.arrayNewListC.length; i++){
	                if (vm.arrayNewListC[i] == rowData.code){
	                    //根据索引值删除arrayNewList中的数据
	                	RemoveValByIndex(vm.arrayNewListC, i);
	                	RemoveValByIndex(vm.columnContC, i);
	                    i--;
	                }
	             }
	        }
			//解决jqGrid不能刷新的问题
			$("#cqgrid").jqGrid('clearGridData');
			$("#cqgrid").trigger('reloadGrid');
		
		},
		showbody : function() {
			
			 var lastsel3;
			    $("#bodyGrid").jqGrid({
			        url: vm.billdata,
			        datatype: "json",
			        colModel: [			
					{ label: 'id', name: 'id', index:'id', width: 50, key: true ,hidden:true	},
						{ label: '最小值（含）', name: 'minNo',index:'minNo', width: 80,editable:true,edittype:'text' },
					
						{ label: '最大值（不含）', name: 'maxNo',index:'maxNo', width: 80,editable:true,edittype:'text'},
						{ label: '系数值', name: 'oyaltyRate',index:'oyaltyRate', width: 80,editable:true,edittype:'text'}		
			        ],
			        cellEdit:true,
			        forceFit : true,
			        cellsubmit : 'clientArray',
			        cellurl:vm.billdata,
					viewrecords: true,
			        height:'100%',
			        rowNum: 9999,
					rowList : [10,30,50],
			        rownumbers: true, 
			        rownumWidth: 50, 
			        width:window.screen.availWidth-260,  
			        autowidth: false,  
			        shrinkToFit: true,
			        sortable:true,
			        multiselect: false,
			        pager: "#bodyGridPager",
			       /* onCellSelect:function(rowid,iCol,cellcontent,e)
			        {
			        	yyyyyy=rowid;
			        	console.log("rowid"+rowid);
			        	console.log("iCol"+iCol);
			        },*/
			        // 点击事件 onSelectRow: function(id) {
			       onSelectRow : function(id) {
			        	// console.log(1);
			        	// console.log(id);
			            if (id && id != lastsel3) {
			 
				      //$("#bodyGrid").saveRow(lastsel3);
		              // $('#bodyGrid').jqGrid('saveRow', lastsel3);
		              $('#bodyGrid').jqGrid('editRow',lastsel3,false);  
			 
			            }
			            lastsel3 = id;
			            $('#bodyGrid').jqGrid('editRow',id,true);  
			          },
			          
			        jsonReader : {
			            root: "page.list",
			            page: "page.currPage",
			            total: "page.totalPage",
			            records: "page.totalCount"
			        },
			       
			        gridComplete:function(){
			        	$("#bodyGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
			        },
			        onCellSelect: function (){
//form.render();
			        }
			    }).setGridParam({url:vm.billdata}).trigger('reloadGrid');
			  //调整表格宽度
				  $("#bodyGrid").jqGrid("setGridWidth",vm.$el.offsetWidth*0.85,true);
		},
		query: function () {
			vm.reload();
		},
		add: function(){
			vm.showList = false;
			vm.title = "新增";
			vm.billdata="";
			$("#bodyGrid").jqGrid('clearGridData');
			vm.dictCoefficient = {};
			vm.showbody();
			addRow();
		},
		update: function (event) {
			var id = getSelectedRow();
			if(id == null){
				return ;
			}
			vm.showList = false;
            vm.title = "修改";
            
            vm.getInfo(id)
		},
		saveOrUpdate: function (event) {
			var ids=$("#bodyGrid").jqGrid("getDataIDs");
			if(ids==null||ids==""){
				return;
			}
			for(var i=0;i<ids.length;i++){
				var rowData = $("#bodyGrid").jqGrid("getRowData", ids[i]);
				if(rowData.minNo==null||rowData.minNo=="") {
					layer.alert("您有一条数据未填全！");
					return ;
				}
				if(rowData.minNo.indexOf("input") >-1) {
					layer.alert("请先退出编辑状态，再保存！");
					return ;
				}
				if(rowData.maxNo.indexOf("input") >-1) {
					layer.alert("请先退出编辑状态，再保存！");
					return ;
				}
				if(rowData.oyaltyRate.indexOf("input") >-1) {
					layer.alert("请先退出编辑状态，再保存！");
					return ;
				}
				var patm=/^(0|[1-9]\d*)(.[0-9]{1,6})?$/;
				if(!patm.test(rowData.minNo) || !patm.test(rowData.maxNo) || !patm.test(rowData.oyaltyRate)) {
					console.log()
					layer.alert("请输入非负数！(最多保留6位小数)");
					return ;
				}
			}
			var columnCodes=[];//初始化一个数组 
			$(ids).each(function (index, yu) {//遍历每个id 找到每个data 并把属性加到初始化数组里
				var rowData = $("#bodyGrid").jqGrid("getRowData", yu);
				var entryData={
						"coefficientId":"",
					"minNo":rowData.minNo,
					"maxNo":rowData.maxNo,
					"oyaltyRate":rowData.oyaltyRate
				};
				columnCodes.push(entryData);
				});
			if(vm.dictCoefficient.id == null) {
				var url = "../dictcoefficient/saveXtd";
				var ycurl ="../dictcoefficientdetail/saveBatch";
				
				$.ajax({
					type: "POST",
				    url: url,
				    data: JSON.stringify(vm.dictCoefficient),
				    success: function(r){
				    	if(r.code === 0){
				    		for(var i=0;i<columnCodes.length;i++){
				    			columnCodes[i].coefficientId=r.id;
				    		}
				    		$.ajax({
										type: "POST",
									    url: ycurl,
									    data: JSON.stringify(columnCodes),
									    success: function(r){
									    	if(r.code === 0){
												layer.alert('操作成功', function(index){
													vm.reload();
													layer.close(index);
												});
											}else{
												layer.alert(r.msg);
											}
										}
									});
						}else{
							layer.alert(r.msg);
						}
					}
				});
			}else{
				/*var url =  "../dictcoefficient/update";
				var ycurl = "../hbconstitute/updateBatch";
				$.ajax({
					type: "POST",
				    url: url,
				    data: JSON.stringify(vm.dictCoefficient),
				    success: function(r){
				    	if(r.code === 0){
				    		$.ajax({
										type: "POST",
									    url: ycurl,
									    data: JSON.stringify(columnCodes),
									    success: function(r){
									    	if(r.code === 0){
												layer.alert('操作成功', function(index){
													vm.reload();
													layer.close(index);
												});
											}else{
												layer.alert(r.msg);
											}
										}
									});
						}else{
							layer.alert(r.msg);
						}
					}
				});*/
			}
			var url = vm.dictCoefficient.id == null ? "" : "";
			$.ajax({
				type: "POST",
			    url: url,
			    data: JSON.stringify(vm.dictCoefficient),
			    success: function(r){
			    	if(r.code === 0){
						alert('操作成功', function(index){
							vm.reload();
						});
					}else{
						alert(r.msg);
					}
				}
			});
		},
		del: function (event) {
			var ids = getSelectedRows();
			if(ids == null){
				return ;
			}
			
			confirm('确定要删除选中的记录？', function(){
				$.ajax({
					type: "POST",
				    url: "../dictcoefficient/delete",
				    data: JSON.stringify(ids),
				    success: function(r){
						if(r.code == 0){
							alert('操作成功', function(index){
								$("#jqGrid").trigger("reloadGrid");
							});
						}else{
							alert(r.msg);
						}
					}
				});
			});
		},
		getInfo: function(id){
			$.get("../dictcoefficient/info/"+id, function(r){
                vm.dictCoefficient = r.dictCoefficient;
            });
		},
		reload: function (event) {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam',{ 
                page:page
            }).trigger("reloadGrid");
		}
	}
});
//grid添加新的一行
var newrowid ;  
function addRow()  
{  
    //$("#operate").val("");  
    var selectedId = $("#bodyGrid").jqGrid("getGridParam", "selrow");   
    var ids = jQuery("#bodyGrid").jqGrid('getDataIDs');  
    if(ids==""||ids==null){
    	ids.push(0);
    }
    // console.log(ids);
    // 获得当前最大行号（数据编号）
    var rowid = Math.max.apply(Math,ids);
    // console.log(rowid);
    // 获得新添加行的行号（数据编号）
    newrowid = rowid+1;  
    // console.log(newrowid);
    var dataRow = {    
        id: newrowid,  
        minNo:"",  
        maxNo:'',  
        oyaltyRate:''
    };      
      
    // 将新添加的行插入到第一列
    $("#bodyGrid").jqGrid("addRowData", newrowid, dataRow, "last");  
    // 设置grid单元格不可编辑
    $("#bodyGrid").setGridParam({cellEdit:true}); 
    // 设置grid单元格可编辑
 // $('#bodyGrid').jqGrid('editRow', newrowid, false);
    // 确定按钮可用
    //$("#confirm_btn").attr("disabled",false);  
    // 给添加的列加选择按钮
    var $zoneInput = $("#"+newrowid);  
    $zoneInput.attr("disabled",true).css("width",100);  
   /*
	 * $zoneInput.after("<input type='button' value='选择'
	 * onclick='fnCallDialogForEidt()' />");
	 */
      
} 
function gridValidate(id) {
	var grid = $("#" + id);
	grid.one('blur', '[type="text"]', function() {
		var val = $(this).val(), _self = this;
		var name = $(this).attr('name');
	
		
			if (name === 'mqty') {
				if(val.indexOf("input") >-1) {
					layer.alert("请先在系数规则里退出编辑状态");
					gridValidate(id);
					return ;
				}
				var patm=/^(0|[1-9][0-9]*)+(.[0-9]{1,2})?$/;
				if(!patm.test(val)) {
					gridValidate(id);
					return ;
				}
				var price = grid.jqGrid("getCell", grid.jqGrid('getGridParam', 'selrow'),
						"price");
				var andprice = (parseFloat(val) * price).toFixed(3);
				//grid.jqGrid("setCell", grid.jqGrid('getGridParam', 'selrow'), "mqty", val);
				grid.jqGrid("setCell", grid.jqGrid('getGridParam', 'selrow'), "andprice", andprice);
				vm.zidongauCom(val);
			}
			//grid.jqGrid("setCell","6777", "andprice", "1111");
			gridValidate(id);
		
	})

	/*grid.on('change', '[name="uname"]', function() {
		grid.jqGrid("setCell", grid.jqGrid('getGridParam', 'selrow'), "unit",
				$(this).val());
	})*/
}
function RemoveValByIndex(arr, index) {
	  arr.splice(index, 1);
	}